#ifndef CONTROLWIDGET_H
#define CONTROLWIDGET_H

#include <QWidget>
#include <qstandarditemmodel.h>
#include <qabstractitemmodel.h>
#include <string.h>
#include <qtableview.h>
#include <qheaderview.h>
#include <qgridlayout.h>
#include <qpainter.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <QCheckBox>
#include <QComboBox>
#include <QRadioButton>
#include <QPushButton>
#include <QSlider>
#include <QSpinBox>
#include <qboxlayout.h>
#include"conditiondialog.h"
#include<QEvent>


class clsContract{
public:
    QString strContract;
    ///涨停板价格
    double  dHighestPrice;
    ///跌停板价格
    double  dLowestPrice;
    QString strfutuExchType;

};

class ControlWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ControlWidget(QWidget *parent = 0);


    void setupViews();

	QString GetContractCode();
	int     GetTotalHands();
	QString GetFutuExchType();

    void SetOrderInfo(char bs,char c_direction,char c_hedge,double en_entrust_price,int FocusType);

    void SetEnableAmount(int iAmount);

signals:
    bool SigOrderInsert(const char* exch_type, const char* contract_code, char c_bs, char c_direction, char c_hedge, int l_entrust_amount, double en_entrust_price);

    void SigGetOpenRatio(char bs,QString ordertype,QString futucode,double price);

public slots:
    void SlotValueChanged(double price);

    void SlotUpdateShowInfo(double buy1, double buy1cnt,double sell1,double sell1cnt);

    void SlotSetHandsTimes(int times);

    void SlotBuyRadioBtnClicked();
    void SlotSellRadioBtnClicked();

    //委托按钮触发事件响应
    void OnEntrust();
    //点击预埋按钮事件响应
    void OnPreEntrust();

	void SelectContract(const QModelIndex & index);
    void OrderTypeChanged(QString OrderType);
protected:
    bool eventFilter(QObject *obj, QEvent *ev);

public:
    QTableView*			tableOrder;
    QAbstractItemModel *modelOrder;
    QPushButton *		ProdButton;
    QLineEdit*			CurrentTime;
    QLineEdit *			EditContract;
    QPushButton *		FreezeButton;
    QComboBox*          m_AccountCombox;
    conditionDialog*    m_conditionDialog;

private:

    QLabel* LabelCnt;
    QLabel* LabelBuy1;
    QLabel* LabelSell1;
    QLabel* LabelBuy1Cnt;
    QLabel* LabelSell1Cnt;
    QLabel* LabelTop;
    QLabel* LabelBottom;

    QVector<clsContract> m_vContracts;
    bool                 m_bAutoFlg;
    
    //批量下单的单号
    int        m_BatchNO;

    double      m_dHighestPrice;
    double      m_dLowestPrice;
    QString     m_futu_exch_type;

    QCheckBox *m_AccountCheckbox;

    QComboBox *m_OrderTypeCombox;
    QCheckBox *m_OrderTypeCheckbox;

    QLineEdit* m_ContractLineEdit;

    QRadioButton* m_BSRadioButton1;
    QRadioButton* m_BSRadioButton2;

    QRadioButton* m_OCRadioButton1;
    QRadioButton* m_OCRadioButton2;
    QRadioButton* m_OCRadioButton3;

	QCheckBox*    m_CancelCheckBox;
	QSpinBox*     m_RiskSpinBox;

    QDoubleSpinBox *m_SpecifiedPriceSpinBox;
    QPushButton *m_SpecifiedPriceButton;

    QSpinBox *m_OrderCntSpinBox;
	QSpinBox *m_HandsTimesSpinBox;

    QPushButton *m_OrderButton;
    QPushButton *m_ConditionButton;
    QPushButton *m_PreentrustButton;

    QItemSelectionModel *selectionModel;
    QGridLayout *MainLayout;
    QBoxLayout *DropLayout,*QuickLayout;
};

#endif // CONTROLWIDGET_H
